You are here: Symbol Reference > Dew Namespace > Dew.Signal Namespace > Dew.Signal.Units Namespace > Classes > SignalUtils Class > SignalUtils Methods > SignalUtils.IirInitBQ Method
Dew Signal for .NET
ContentsIndexHome
Example

Lowpass filter a sine signal with Chebyshev type I filter. Sampling frequency is 2Hz, cutoff frequency is 0.6 Hz. Passband ripple is 0.2 dB and filter order is 6.

using Dew.Math; using Dew.Math.Editors; using Dew.Math.Units; using Dew.Signal; using Dew.Signal.Units; using Dew.Math.Tee; using Dew.Signal.Tee; private void button1_Click(object sender, EventArgs e) { Vector b = new Vector(0); Vector c = new Vector(0); Vector sos = new Vector(0); Vector Response1 = new Vector(0); Vector Response2 = new Vector(0); TIirState state = new TIirState(); int n; int i; SignalUtils.Tone(b,300,6.0/300,0,1,false); // Alternative: try gaussian noise // b = MtxExpr.RandGauss(300); IIRFilters.ChebyshevIFilter(6,0.2,new double[1] {0.6}, TFilterType.ftLowpass,false,sos,TIirFrequencyTransform.ftStateSpaceAnalog); SignalUtils.IirInit(sos,ref state,false); try { c.Copy(b); //backup data SignalUtils.IirFilter(c,state); //apply filter to the data } finally { SignalUtils.IirFree(ref state); //free structure, if you dont require this IIR filter anymore } MtxVecTee.DrawIt(new TVec[2] {b,c}, new string[2] {"Original signal","Filtered signal"},"Time signals", false); SignalUtils.FrequencyResponse(c, null, Response1, 1, true, TSignalWindowType.wtHanning, 0); SignalUtils.FrequencyResponse(b, null, Response2, 1, true, TSignalWindowType.wtHanning, 0); MtxVecTee.DrawIt(new TVec[2] {Response1,Response2}, new string[2] {"Spectrum: original signal","Spectrum: filtered signal"}, "Frequency spectrum", false); }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.